use std::{io};
use std::cmp::Ordering;
use rand::Rng;

fn task_string(some: &mut String){
    let  some1: String="abc".to_string();
    //some1.push_str("abc");
    //println!("值:{}",some1)
  
}
#[derive(Debug)]
struct User{
    sex:bool,
    age:u64,
    username:String
}
impl User{
    fn addage(&mut self,ohter:&User){
      self.age=  self.age+ohter.age;
    }
}
fn getUser(username:String,age:u64)->User{
    User { sex: false, age, username }
}
fn task_int(some: i32){
    let some =some+1;
    println!("{}",some);
}
fn plus_one(x:Option<i32>)->Option<i32>{
    match x{
        Some(i)=>return Some(i+1),
        None=>None
    }
}
enum IpAddr{
    V4(u8,u8,u8,u8),
    V6(String)
}
fn main() {
    let pluso:Option<i32>=plus_one(Option::Some(100));
    print!("值:{}",pluso.unwrap());
    let home=IpAddr::V4(127, 0, 0, 1);
    let loopback=IpAddr::V6(String::from("192.168.3.1"));

    let mut s:String=String::from("nihao");
    let mut usera:User=getUser("郝斌斌".to_string(), 15);
    let userb:User=getUser("郝斌斌".to_string(), 15);
    usera.addage(&userb);
    println!("结果:{:?}",usera);
    println!("结果1:{:?}",userb);
    task_string(&mut s);
    println!("值:{}",s);
    // loop{
    //     let secret_number= rand::thread_rng().gen_range(1..101);
    //     println!("the seret number is:{}",secret_number);
    //     println!("please input your guess,quit:exit");
    //     let mut guess: String=String::new();
    //     io::stdin().read_line(&mut guess)
    //     .expect("faild to read line");
    //     println!("你输入的值：{}",guess);
    //     if guess.trim_end().eq("exit") {
    //         println!("退出了");
    //         break;
    //     }
    //     let guess: u32=match guess.trim().parse(){
    //         Ok(num) =>num,
    //         Err(err) =>{
    //             println!("异常信息:{}",err.to_string());
    //             continue;
    //         }
    //     };
    //     println!("you guessed:{}",guess);
    //     match guess.cmp(&secret_number) {
    //         Ordering::Less => println!("Too small"),
    //         Ordering::Greater => println!("Too bud") ,
    //         Ordering::Equal => {
    //             println!("you win!");
    //             break;
    //         }
    //     }
    // }
    
   


}
